package com.base.controller;

import com.base.po.tbk.TbkBrandShop;
import com.base.po.tbk.TbkChoiceActivity;
import com.base.service.LogsService;
import com.base.service.TbkBrandShopService;
import com.base.service.TbkChoiceActivityService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;

import javax.servlet.http.HttpServletRequest;
import java.util.List;

/**
 * 修改信息服务端
 * 
 */
@Controller
@RequestMapping("/admin")
public class update_TbkBrandShop {

	@Autowired
	private LogsService logsService; // log日志
	@Autowired
	private TbkBrandShopService tbkBrandShopService; // 分类信息

	// 修改分类信息
	@RequestMapping(value = "/toUpdateTbkBrandShop", method = RequestMethod.POST)
	public @ResponseBody int toUpdateTbkBrandShop(HttpServletRequest request, TbkBrandShop tbkBrandShop) {
		if (request.getSession().getAttribute("adminUserId") == null) return -1; // 未登录

		List<TbkBrandShop> tbkBrandShopList = tbkBrandShopService.selectByName(tbkBrandShop.getName());
		if (tbkBrandShopList != null && tbkBrandShopList.size() > 0){
			return -2;
		}

		return tbkBrandShopService.updateByPrimaryKeySelective(tbkBrandShop); // 修改
	}
}
